package com.aaa.java08;

import cn.hutool.core.util.ObjectUtil;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/7/11 16:15
 * @description：儿子类
 * @modified By：
 * @version: 1.0
 */
public class Son  extends Father {
    private boolean sex;
    public void code(){
        System.out.println("编码");
    }

    public Son() {
        //super();隐藏
        System.out.println("子类无参构造器被调用了");
    }

    public Son(int id, String name) {
        super(id, name);
        System.out.println("子类有参构造器被调用了");
    }

    public Son(boolean sex) {
        //super();隐藏,默认调用父类的无参
        this.sex = sex;
    }

    public Son(int id, String name, boolean sex) {
        super(id, name);
        this.sex = sex;
    }


    @Override
    public void work() {
        System.out.println("上班挣钱20000");
    }


    @Override
    protected Integer add(int a, int b)  throws ArrayIndexOutOfBoundsException   {
        System.out.println("子类的加法函数被调用了");
       // super.add(a, b);
        return b+a;
    }
/*
    @Override
    protected Number add(int a, int b) throws ArrayIndexOutOfBoundsException {
        return super.add(a, b);
    }*/
/*    @Override
    protected Number add(int a, int b) throws RuntimeException {
        return super.add(a, b);
    }*/

    public static void main(String[] args) {
     //   Son son= new Son();
        Son son= new Son(12,"张三");
      /*  son.name="fdsaf";
        son.eat();
        son.work();
        son.code();*/
        Integer add = son.add(10, 20);
        System.out.println(add);
    }
}
